cmake_minimum_required(VERSION 3.10)
project(MyGtestProject)

# 设置C++标准
set(CMAKE_CXX_STANDARD 11)

# 查找gtest库（Windows用vcpkg安装时需要这行）
if(WIN32)
    set(CMAKE_TOOLCHAIN_FILE "F:/vscodedaimavcpkg/scripts/buildsystems/vcpkg.cmake")
endif()

find_package(GTest REQUIRED)

# 生成测试可执行文件
add_executable(MyTests test.cpp)

# 链接gtest库
target_link_libraries(MyTests GTest::GTest GTest::Main)

# 启用测试
enable_testing()
add_test(NAME MyTests COMMAND MyTests)